< previous page page_60 next page >

Page 60
12181-0060a.gif
Figure 2.8.
Creating a Color dialog box to
interact with users.
The difference with this example is that you're displaying the current color to users before it's changed and then after it changes. In the Form_Load routine, the labels used to display the current colors will be set. To see this first step in the process, add the following code to your new form:
lblAppBack.BackColor = frmDialog.BackColor
lblTxtBack.BackColor = frmDialog!txtSourceFile.BackColor
Before running the application, you must change the code in the cmdColor_Click routine to the following:
FrmColor.Show VBModal, Me
This code enables you to display the new form. It also prevents users from doing anything else until they finish with the colors. When you run the application, you'll see the default colors for these properties.
For the next step, add the following code to each of the two color labels double-click routines, to change the label name to the respective control:
Private Sub lblAppBack_Click()
    dlgColor.Color = lblAppBack.BackColor
    dlgColor.ShowColor
    lblAppBack.BackColor = dlgColor.Color
End Sub

Private Sub lblTxtBack_Click()
    dlgColor.Color = lblTxtBack.BackColor
    dlgColor.ShowColor
    lblTxtBack.BackColor = dlgColor.Color
End Sub
This code shows the Color dialog box. When the dialog box changes, change the labels color accordingly. Try the application again and change the colors a few times.

 
< previous page page_60 next page >

If you like this book, buy it!